/**
 * huize Service Inc
 * All Rights Reserved @2018
 */
package com.huize.zhike.framework.common.param;

import com.huize.zhike.framework.common.enumeration.StatTypeEnum;
import com.huize.zhike.framework.common.util.DatetimeUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;

/**
 * 描述:
 *
 * @author tianyuliang
 * @version $Id: DateRangeParam.java, v0.1 2021/2/4
 */
@Getter
@Setter
@NoArgsConstructor
@ToString
public class DateRangeParam {

    /**
     * 开始日期(yyyyMMdd)
     */
    private String start;

    /**
     * 结束日期(yyyyMMdd)
     */
    private String end;

    /**
     * 开始日期
     */
    private Date startDate;

    /**
     * 结束日期
     */
    private Date endDate;

    /**
     * 数据统计类型
     */
    private String statType;

    /**
     * 统计类型枚举
     */
    private StatTypeEnum statTypeEnum;

    public DateRangeParam(String start, String end, StatTypeEnum statTypeEnum) {
        this.start = start;
        this.end = end;
        this.startDate = DatetimeUtils.parseExtDate(start);
        this.endDate = DatetimeUtils.parseExtDate(end);
        this.statType = statTypeEnum.getType();
        this.statTypeEnum = statTypeEnum;
    }

    public DateRangeParam(Date startDate, Date endDate, StatTypeEnum statTypeEnum) {
        this.startDate = startDate;
        this.endDate = endDate;
        this.start = DatetimeUtils.formatExtDate(startDate);
        this.end = DatetimeUtils.formatExtDate(endDate);
        this.statType = statTypeEnum.getType();
        this.statTypeEnum = statTypeEnum;
    }

}